<?php
namespace Admin\Controller;
use Think\Controller;
class StystemController extends PublicController {
    public function configAction(){
		$Model=D("Config"); // 实例化config对象
		
		//编辑的
		$one=$Model->where(' id=1 ')->find();
		
		$this->assign('one',$one);// 赋值分页输出
		
		//上传水印图片
		if(!empty($_FILES['logo']['name'])){	
			$finfo=$this->uploadOne('logo');	
		}
		$filesinfo='Public/'.$finfo['savepath'].$finfo['savename'];
		
		
		
		$data=I('post.');
		
		if(!empty($data)){
			
			if(!empty($_FILES['logo']['name'])){
				$data['waterimage']=$filesinfo;
				}else{
					unset($data['waterimage']);
					}
			
			
			
			//print_r($data);die;
			
			$conf=$Model->where(' id=1 ')->data($data)->save();
			if($conf){
				$this->success('设置成功', U('stystem/config'));
				die();
				}else{
					$this->error('设置失败');
					die();
				}
			
			}
			
		$this->display('stystem:config');
    }
}